﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ettevotja_muudatus_maarus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(EttevotjaMuudatusMaarus))]
    public class EttevotjaMuudatusMaarusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEttevotjaMuudatusMaarus clazz;
        
        public EttevotjaMuudatusMaarusSerializer(IEttevotjaMuudatusMaarus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EttevotjaId!=null) {
                Writer.WriteStartElement("ettevotja_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaAriregistriKood!=null) {
                Writer.WriteStartElement("ettevotja_ariregistri_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.EttevotjaAriregistriKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaArinimi!=null) {
                Writer.WriteStartElement("ettevotja_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaOiguslikVorm!=null) {
                Writer.WriteStartElement("ettevotja_oiguslik_vorm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaOiguslikVorm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Piirkond!=null) {
                Writer.WriteStartElement("piirkond");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Piirkond))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Olek!=null) {
                Writer.WriteStartElement("olek");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OlekuKpv!=null) {
                Writer.WriteStartElement("oleku_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.OlekuKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OtsuseId!=null) {
                Writer.WriteStartElement("otsuse_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OtsuseId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OtsuseNr!=null) {
                Writer.WriteStartElement("otsuse_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OtsuseNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OtsuseLiik!=null) {
                Writer.WriteStartElement("otsuse_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OtsuseLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kandeliik!=null) {
                Writer.WriteStartElement("kandeliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kandeliik))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ettevotja_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>ettevotja_id");
                }
                clazz.EttevotjaId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_id")).Value;
            }
            if (Reader.LocalName=="ettevotja_ariregistri_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>ettevotja_ariregistri_kood");
                }
                clazz.EttevotjaAriregistriKood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ettevotja_ariregistri_kood")).Value;
            }
            if (Reader.LocalName=="ettevotja_arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>ettevotja_arinimi");
                }
                clazz.EttevotjaArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_arinimi")).Value;
            }
            if (Reader.LocalName=="ettevotja_oiguslik_vorm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>ettevotja_oiguslik_vorm");
                }
                clazz.EttevotjaOiguslikVorm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_oiguslik_vorm")).Value;
            }
            if (Reader.LocalName=="piirkond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>piirkond");
                }
                clazz.Piirkond = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("piirkond")).Value;
            }
            if (Reader.LocalName=="olek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>olek");
                }
                clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            }
            if (Reader.LocalName=="oleku_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>oleku_kpv");
                }
                clazz.OlekuKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("oleku_kpv")).Value;
            }
            if (Reader.LocalName=="otsuse_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>otsuse_id");
                }
                clazz.OtsuseId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsuse_id")).Value;
            }
            if (Reader.LocalName=="otsuse_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>otsuse_nr");
                }
                clazz.OtsuseNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsuse_nr")).Value;
            }
            if (Reader.LocalName=="otsuse_liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>otsuse_liik");
                }
                clazz.OtsuseLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("otsuse_liik")).Value;
            }
            if (Reader.LocalName=="kandeliik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_maarus>kandeliik");
                }
                clazz.Kandeliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kandeliik")).Value;
            }
        }
    }
}
